package dynamicplanning;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Package1 {
    public static int packageProblem2() {
        int packageContainWeight = 4;
        int[] weight = {1, 4, 3};
        int[] value = {150, 300, 200};
        int[] dp = new int[packageContainWeight + 1];
        for (int i = 1; i <= value.length; i++) {
            for (int j = packageContainWeight; j >= 1; j--) {
                if (j - weight[i - 1] >= 0)
                    dp[j] = Math.max(dp[j], dp[j - weight[i - 1]] + value[i - 1]);
            }
            System.out.println();
        }
        return dp[packageContainWeight];
    }
}

class MainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
            return new int[0];
        }

        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for (int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }

        return output;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums = stringToIntegerArray(line);
            line = in.readLine();
            int target = Integer.parseInt(line);

            int ret = Package1.packageProblem2();

            String out = String.valueOf(ret);

            System.out.print(out);
        }
    }
}

